import router from '../router/router.js'
import { getUrlParams } from '../utils/mUtils.js'
import store from '../store'
router.beforeEach(async(to, from, next) => {
  if (to.fullPath === '/redirect') {
    next()
  }
  let params = getUrlParams()
  if (params.ticket) {
    const result = await store.dispatch('getTicker', { ticket: params.ticket })
    let data = result.data
    if (data.code === '200') {
      next({ path: '/redirect' })
    }
  } else {
    next()
  }
})
